<?php

// login.php
// Michael Baker
// 2010.07.12
//
// Allows a user to log in

session_start();

define("IN_MDM", true);
define("IN_LOGIN", true);
define("CUR_PAGE_TITLE", "Login");

include '../includes/all.php';

$usr = $_POST["username"];
$pwd = $_POST["pwd"];

$failed = 0;

if ( $usr && $pwd ) {
  $success = login($usr, $pwd);
  $_SESSION["uid"] = $success;
  if ( $success ) {
    header( "Location: index.php" );
    die;
  }
  else { $failed = 1; }
}

include 'inc/header.php';

?>
<p>Please log in to the administrative panel.
<?php

if ( $failed ) {
  echo "<br /><br /><span class=\"error\">Login failed. Please try again.</span>";
}

?>
</p>
<form id="select_user" method="post" action="login.php">

  <fieldset>
    <dl>
      <dt><label for="username">Username</label></dt>
      <dd><input class="text medium" type="text" id="username" name="username" /></dd>
    </dl>
    
    <dl>
      <dt><label for="pwd">Password</label></dt>
      <dd><input class="text medium" type="password" id="pwd" name="pwd" /></dd>
    </dl>
    
    <p>
      <input type="submit" name="submituser" value="Submit" class="button1" />
    </p>
  </fieldset>

</form>
<?php include 'inc/footer.php'; ?>